package com.asa.chart;

import java.util.ArrayList;
import java.util.List;

import com.asa.HanShu;
import com.asa.chart.work.AlgoVisualizer;
import com.asa.control_theory.A;

/**
 * 
 * 画函数(只能画实数)
 * 
 * 预留100X600做操作面板
 * 
 * @author asa
 *
 */
public class Main {
	
	public static void main(String[] args) throws Exception {
		
		
		final int sceneWidth = 900;
		final int sceneHeight = 900;
		int N = 10;

		
//		List<double[][]> zhi = ATest();
		
		
		List<double[][]> zhi = new ArrayList<double[][]>();//函数的线簇

		
		HanShu hanShu = new HanShu() {
			
			@Override
			public double hanshu(double t, double x) {
				// TODO Auto-generated method stub
				return x;
			}
			
			@Override
			public double hanshu(double x) {
				// TODO Auto-generated method stub
//				if (x>0) {
//					return Math.exp(-x);
//				}else {
//					return Math.exp(x);
//				}
				
				
				return Math.cos(x)+1;
				
//				return Math.pow(x, 4) - 10*Math.pow(x, 2)+1;
			}
		};
		double[][] hanshupoint = MathPointUtil.hanshupoint(hanShu,-9,6);
		zhi.add(hanshupoint);
		
		
//		System.out.println(Math.exp(-9));
		
		
		
		AlgoVisualizer algoVisualizer = new AlgoVisualizer(sceneWidth, sceneHeight, N,zhi,50);
		
		
		System.out.println(algoVisualizer);
		
		
	}

	
	
	
	
	
	
	
	
	private static List<double[][]> ATest() {
		List<double[][]> zhi = new ArrayList<double[][]>();//函数的线簇

		
		HanShu hanShu = new HanShu() {
			
			@Override
			public double hanshu(double t, double x) {
				// TODO Auto-generated method stub
				return x;
			}
			
			@Override
			public double hanshu(double x) {
				// TODO Auto-generated method stub
				return 4;
			}
		};
		double[][] hanshupoint = MathPointUtil.hanshupoint(hanShu);
		zhi.add(hanshupoint);
//
//		
//		HanShu hanShu2 = new HanShu() {
//			
//			@Override
//			public double hanshu(double t, double x) {
//				// TODO Auto-generated method stub
//				return x;
//			}
//			
//			@Override
//			public double hanshu(double x) {
//				// TODO Auto-generated method stub
//				return 2*Math.exp(2*x)+2* Math.exp(-3*x);
//			}
//		};
//		double[][] hanshupoint2 = MathPointUtil.hanshupoint(hanShu2);
//		zhi.add(hanshupoint2);
//		
//		HanShu hanShu3= new HanShu() {
//			
//			@Override
//			public double hanshu(double t, double x) {
//				// TODO Auto-generated method stub
//				return x;
//			}
//			
//			@Override
//			public double hanshu(double x) {
//				// TODO Auto-generated method stub
//				return -2*Math.exp(2*x)+(-2)* Math.exp(-3*x);
//			}
//		};
//		double[][] hanshupoint3 = MathPointUtil.hanshupoint(hanShu3);
//		zhi.add(hanshupoint3);
		
		
		
		
		
		
		
		
		
		
		
		double[][] a = {
				{1, 1},
				{4, -2}
			};
		
		List<List<HanShu>> onepiece = A.onepiece(a,3);

		for (int i = 0; i < onepiece.size(); i++) {
			List<HanShu> hanshulist = onepiece.get(i);
			HanShu hanShu4 = hanshulist.get(0);
			
			
			double[][] hanshupoint4 = MathPointUtil.hanshupoint(hanShu4);
			zhi.add(hanshupoint4);
		}
		
		
		
		
		
		
		
		
//		zhi.add(hanshupoint3);
		return zhi;
	}
	
	
	
	
	

	
	
	
	
	

}
